//基于axios的一些封装
import axios from "axios";
import { ElMessage } from "element-plus";



//创建实例
const http = axios.create({
  baseURL: 'http://localhost:8080',  //你的后端服务地址
  timeout: 5000
})

// axios请求拦截器
http.interceptors.request.use(config => config, e => Promise.reject(e))

// axios响应式拦截器
http.interceptors.response.use(res =>res.data,e => {
    ElMessage.error(e.response?.data?.message)
    return Promise.reject(e)
  },
)

export default http